home *** CD-ROM | disk | FTP | other *** search
/ One Click 14 / OneClick14.iso / Ferramentas / Convert XLS to Pdf / xls2pdf_setup.exe / {app} / lib / gs_ll3.ps < prev    next >
Encoding:
Text File  |  2002-09-11  |  12.0 KB  |  383 lines

  1. %    Copyright (C) 1997, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_ll3.ps,v 1.17 2002/09/10 22:16:05 dan Exp $
  14. % Initialization file for PostScript LanguageLevel 3 functions.
  15. % This file must be loaded after gs_lev2.ps and gs_res.ps.
  16. % These definitions go into ll3dict or various ProcSets.
  17. % NOTE: the interpreter creates ll3dict.
  18.  
  19. ll3dict begin
  20.  
  21. % We need LanguageLevel 2 or higher in order to have setuserparams and
  22. % defineresource.
  23. languagelevel dup 2 .max .setlanguagelevel
  24.  
  25. % ------ Idiom recognition ------ %
  26.  
  27. /IdiomRecognition false .definepsuserparam
  28.  
  29. % Modify `bind' to apply idiom recognition afterwards.
  30. /.bindscratch 128 string def
  31. % Do the right thing if NOBIND or DELAYBIND is in effect.
  32. % Note also that since this definition of `bind' may get bound in,
  33. % it has to function properly even at lower language levels,
  34. % where IdiomRecognition may not be defined.
  35. /bind load /.bind load ne
  36. /bind {        % <proc> bind <proc'>
  37.   //.bind currentuserparams /IdiomRecognition
  38.   .knownget not { false } if {
  39.     (*) {
  40.       /IdiomSet findresource
  41.       false exch {
  42.         % Stack: proc false dummykey [template substitute]
  43.     exch pop dup 1 get exch 0 get
  44.         % Stack: proc false substitute template
  45.     3 index .eqproc {
  46.       2 index gcheck 1 index gcheck not and {
  47.         pop
  48.       } {
  49.         3 -1 roll pop exch not exit
  50.       } ifelse
  51.     } {
  52.       pop
  53.     } ifelse
  54.       } forall { exit } if
  55.     } //.bindscratch /IdiomSet resourceforall
  56.   } if
  57. } odef
  58. { /.bind /bind load def
  59.   /bind { } def
  60. } if
  61. currentdict /.bindscratch .undef
  62.  
  63. % ------ HalftoneTypes 6, 10, 16 and HalftoneMode ------ %
  64.  
  65. % This code depends on an internal HalftoneType 7 with the following keys:
  66. %    Width, Height, Width2, Height2, TransferFunction:
  67. %      as for HalftoneType 16.
  68. %    Thresholds: a string or bytestring holding the thresholds,
  69. %      (Width x Height + Width2 x Height2) x BitsPerSample / 8 bytes,
  70. %      as for HalftoneType 16 except that the samples may be either
  71. %      8 or 16 bits wide.
  72. %    BitsPerSample: 8 or 16.
  73.  
  74. % Note that this HalftoneType never appears in halftone dictionaries given
  75. % to sethalftone, only as a component in those given to .sethalftone5,
  76. % so its numeric value can be chosen ad lib as long as it differs from the
  77. % other values that are legal in component dictionaries for .sethalftone5
  78. % (currently only 1 and 3).
  79.  
  80. /.makehalftone7 {    % <dict> <dict> <source> <Width> <Height>
  81.             %   (<Width2> <Height2> | null) <BPS> .makehalftone7
  82.             %   <setdict> <dict5> { .sethalftone5 }
  83.   8 dict begin
  84.   /HalftoneType 7 def
  85.   /BitsPerSample exch def
  86.   dup null eq {
  87.     pop 0
  88.   } {
  89.     /Height2 1 index def /Width2 2 index def mul
  90.   } ifelse 3 1 roll
  91.   /Height 1 index def
  92.   /Width 2 index def
  93.   mul add BitsPerSample 8 idiv mul .bigstring
  94.         % Stack: dict dict source str
  95.   dup type /stringtype eq { readstring } { .readbytestring } ifelse
  96.   not { /sethalftone load /rangecheck signalerror exit } if
  97.   readonly /Thresholds exch def
  98.   /TransferFunction .knownget { /TransferFunction exch def } if
  99.         % If the original Thresholds was a file, replace it with
  100.         % a new one.
  101.   dup /Thresholds get type /filetype eq {
  102.     dup /Thresholds [ Thresholds ] cvx 0 () .subfiledecode put
  103.   } if
  104.   mark /HalftoneType 5 /Default currentdict end .dicttomark
  105.   { .sethalftone5 }
  106. } bind def
  107.  
  108. /.bigstring {    % <size> .bigstring <string|bytestring>
  109.   dup 65400 gt { .bytestring } { string } ifelse
  110. } bind def
  111.  
  112. /.readbytestring {    % <source> <bytestring> .readbytestring
  113.             %   <bytestring> <filled>
  114.         % Note that since bytestrings don't implement getinterval,
  115.         % if filled is false, there is no way to tell how much
  116.         % was read.
  117.   true exch 0 1 2 index length 1 sub {
  118.         % Stack: source true str index
  119.     3 index read not { pop exch not exch exit } if
  120.     3 copy put pop pop
  121.   } for 3 -1 roll pop exch
  122. } bind def
  123.  
  124. /.sethalftone6 {    % <dict> <dict> .sethalftone6 <setdict> <dict5>
  125.             %   { .sethalftone5 }
  126.             % Keys: Width, Height, Thresholds, T'Function
  127.   dup /Thresholds get
  128.   1 index /Width get 2 index /Height get
  129.   null 8 .makehalftone7
  130. } bind def
  131.  
  132. /.sethalftone10 {    % <dict> <dict> .sethalftone10 <setdict> <dict5>
  133.             %   { .sethalftone5 }
  134.             % Keys: Xsquare, Ysquare, Thresholds, T'Function
  135.         % Note that this is the only one of these three HalftoneTypes
  136.         % that allows either a file or a string for Thresholds.
  137.   dup /Thresholds get dup type /stringtype eq { 0 () .subfiledecode } if
  138.   1 index /Xsquare get dup 3 index /Ysquare get dup
  139.   8 .makehalftone7
  140. } bind def
  141.  
  142. /.sethalftone16 {    % <dict> <dict> .sethalftone16 <setdict> <dict5>
  143.             %   { .sethalftone5 }
  144.             % Keys: Width, Height, Width2, Height2,
  145.             %   Thresholds, T'Function
  146.   dup /Thresholds get
  147.   1 index /Width get 2 index /Height get
  148.   3 index /Width2 .knownget {  % 2-rectangle case
  149.     4 index /Height2 get
  150.   } {            % 1-rectangle case
  151.     null
  152.   } ifelse 16 .makehalftone7
  153. } bind def
  154.  
  155. .halftonetypes begin
  156.   6 /.sethalftone6 load def
  157.   10 /.sethalftone10 load def
  158.   16 /.sethalftone16 load def
  159. end
  160.  
  161. % Redefine the halftone-setting operators to honor HalftoneMode.
  162. /setcolorscreen {
  163.   /HalftoneMode getuserparam 0 eq {
  164.     //setcolorscreen
  165.   } {
  166.     12 { pop } repeat .getdefaulthalftone
  167.     { //sethalftone }
  168.     { .setdefaulthalftone }
  169.     ifelse
  170.   } ifelse
  171. } odef
  172. /setscreen {
  173.   /HalftoneMode getuserparam 0 eq {
  174.     //setscreen
  175.   } {
  176.     pop pop pop .getdefaulthalftone
  177.     { //sethalftone }
  178.     { .setdefaulthalftone }
  179.     ifelse
  180.   } ifelse
  181. } odef
  182. /sethalftone {
  183.   /HalftoneMode getuserparam 0 eq {
  184.     //sethalftone
  185.   } {
  186.     pop .getdefaulthalftone
  187.     { //sethalftone }
  188.     { .setdefaulthalftone }
  189.     ifelse
  190.   } ifelse
  191. } odef
  192.  
  193. % ------ ImageTypes 3 and 4 (masked images) ------ %
  194.  
  195. .imagetypes
  196.   dup 3 /.image3 load put
  197.   dup 4 /.image4 load put
  198. % We also detect ImageType 103 here: it isn't worth making a separate file
  199. % just for this.
  200.   /.image3x where { pop dup 103 /.image3x load put } if
  201. pop
  202.  
  203. % ------ Functions ------ %
  204.  
  205. % Define the FunctionType resource category.
  206. /Generic /Category findresource dup maxlength 3 add dict .copydict begin
  207.   /InstanceType /integertype def
  208. /FunctionType currentdict end /Category defineresource pop
  209.  
  210. {0 2 3} { dup /FunctionType defineresource pop } forall
  211.  
  212. % ------ Smooth shading ------ %
  213.  
  214. % Define the ShadingType resource category.
  215. /Generic /Category findresource dup maxlength 3 add dict .copydict begin
  216.   /InstanceType /integertype def
  217. /ShadingType currentdict end /Category defineresource pop
  218.  
  219. systemdict /.shadingtypes mark        % not ll3dict
  220.   1 /.buildshading1 load
  221.   2 /.buildshading2 load
  222.   3 /.buildshading3 load
  223.   4 /.buildshading4 load
  224.   5 /.buildshading5 load
  225.   6 /.buildshading6 load
  226.   7 /.buildshading7 load
  227. .dicttomark put
  228.  
  229. systemdict /.reuseparamdict mark
  230.   /Intent 2
  231.   /AsyncRead false
  232.   /CloseSource true
  233. .dicttomark readonly put
  234. /.buildshading {    % <shadingdict> .buildshading <shading>
  235.         % Unfortunately, we always need to make the DataSource reusable,
  236.         % because if clipping is involved, even shfill may need to read
  237.         % the source data multiple times.  If it weren't for this,
  238.         % we would only need to create a reusable stream if the ultimate
  239.         % source of the data is a procedure (since the library can't
  240.         % suspend shading to do a procedure callout).
  241.   dup /DataSource .knownget {
  242.     dup type /filetype eq {
  243.       //.reuseparamdict /ReusableStreamDecode filter
  244.       .currentglobal 1 index gcheck .setglobal
  245.         % Stack: shdict rsdfile saveglobal
  246.       2 index dup length dict copy exch .setglobal
  247.       dup /DataSource 4 -1 roll put exch pop
  248.     } {
  249.       pop
  250.     } ifelse
  251.   } if
  252.     % The .buildshading operators use the current color space
  253.     % for ColorSpace.
  254.   dup /ShadingType get //.shadingtypes exch get
  255.   1 index /ColorSpace get setcolorspace exec
  256. } bind def
  257. systemdict /.reuseparamdict undef
  258.  
  259. /.buildpattern2 {    % <template> <matrix> .buildpattern2
  260.             %   <template> <pattern>
  261.     % We want to build the pattern without doing gsave/grestore,
  262.     % since we want it to load the CIE caches.
  263.   1 index /Shading get
  264.   mark currentcolor currentcolorspace
  265.   counttomark 4 add -3 roll mark 4 1 roll
  266.     % Stack: -mark- ..color.. cspace -mark- template matrix shadingdict
  267.   { .buildshading } stopped {
  268.     cleartomark setcolorspace setcolor pop stop
  269.   } if
  270.   .buildshadingpattern
  271.   3 -1 roll pop counttomark 1 add 2 roll setcolorspace setcolor pop
  272. } bind def
  273.  
  274. .patterntypes
  275.   2 /.buildpattern2 load put
  276.  
  277. /shfill {        % <shadingdict> shfill -
  278.     % Currently, .shfill requires that the color space
  279.     % in the pattern be the current color space.
  280.     % Disable overprintmode for shfill
  281.   dup gsave
  282.   0 .setoverprintmode { .buildshading .shfill } stopped
  283.   grestore { stop } if
  284.   pop
  285. } odef
  286.  
  287. % Establish an initial smoothness value that matches Adobe RIPs.
  288. 0.02 setsmoothness
  289.  
  290. % ------ UseCIEColor ------ %
  291.  
  292. % Define default device color spaces to allow substitution
  293. % on UseCIEColor == true :
  294.  
  295. /DefaultGray
  296. [ /CIEBasedA
  297.   3 dict begin
  298.      /WhitePoint [ 0.9505 1.0 1.089 ] def
  299.      /DecodeLMN  [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ] def
  300.      /MatrixLMN  [ 0.4439 0.2522 0.0436 0.3341 0.6371 0.1387 0.1725 0.1107 0.9067 ] def
  301.   currentdict end
  302. ]
  303. /ColorSpace defineresource pop
  304.  
  305. /DefaultRGB
  306. [ /CIEBasedABC
  307.   3 dict begin
  308.      /WhitePoint [ 0.9505 1.0 1.089 ] def
  309.      /DecodeLMN  [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ]  def
  310.      /MatrixLMN  [ 0.4439 0.2522 0.0436 0.3341 0.6371 0.1387 0.1725 0.1107 0.9067 ] def
  311.   currentdict end
  312. ]
  313. /ColorSpace defineresource pop
  314.  
  315. /DefaultCMYK
  316. [ /CIEBasedDEFG
  317.   4 dict begin
  318.      /WhitePoint [ 0.9505 1.0 1.089 ] def
  319.      /Table [ 2 2 2 2
  320.             % Trivial table :
  321.             % [
  322.             %   [ < FFFFFF 000000 FFFF00 000000>
  323.             %     < FF00FF 000000 FF0000 000000> ]
  324.             %   [ < 00FFFF 000000 00FF00 000000>
  325.             %     < 0000FF 000000 000000 000000> ]
  326.             % ]
  327.  
  328.             % AcrobatReader-compatible table :
  329.               [
  330.                 [ < FFFFFF 000000 FFFF00 000000>
  331.                   < EA007F 000000 FC000F 000000> ]
  332.  
  333.                 [ < 00A0C8 000000 008436 000000>
  334.                   < 00007C 000000 000000 000000> ]
  335.               ]
  336.             ] def
  337.      /DecodeLMN [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ] def
  338.      /MatrixLMN [ 0.4439 0.2522 0.0436 0.3341 0.6371 0.1387 0.1725 0.1107 0.9067 ] def
  339.   currentdict end
  340. ]
  341. /ColorSpace defineresource pop
  342.  
  343.  
  344. % ------ DeviceN color space ------ %
  345.  
  346. %% Replace 1 (gs_ciecs3.ps)
  347. (gs_ciecs3.ps) runlibfile
  348.  
  349. %% Replace 1 (gs_devn.ps)
  350. (gs_devn.ps) runlibfile
  351.  
  352. % ------ Miscellaneous ------ %
  353.  
  354. % Make the .setoverprintmode and .currentoverprintmode operators visible (3015)
  355. systemdict /setoverprintmode /.setoverprintmode load put
  356. systemdict /currentoverprintmode /.currentoverprintmode load put
  357.  
  358. % Define additional user and system parameters.
  359. /HalftoneMode 0 .definepsuserparam
  360. /MaxSuperScreen 1016 .definepsuserparam
  361. pssystemparams begin        % read-only, so use .forcedef
  362.   /MaxDisplayAndSourceList 160000 .forcedef
  363. end
  364.  
  365. % Define the IdiomSet resource category.
  366. { /IdiomSet } {
  367.   /Generic /Category findresource dup maxlength 3 add dict .copydict begin
  368.     /InstanceType /dicttype def
  369.   currentdict end /Category defineresource pop
  370. } forall
  371.  
  372. /languagelevel 3 def
  373. % When running in LanguageLevel 3 mode, this interpreter is supposed to be
  374. % compatible with Adobe version 3010.
  375. /version (3010) readonly def
  376.  
  377. .setlanguagelevel
  378.  
  379. end            % ll3dict
  380.